import org.junit.*;
import static org.junit.Assert.*;
import com.thoughtworks.selenium.*;

import org.junit.Before;
import static org.junit.Assert.*;
import com.thoughtworks.selenium.*;

import org.junit.Before;

public class CredoTest1 {

	Selenium testDriver;
	@Before
	public void setUp() throws Exception {
		testDriver = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.credomobile.com");
		testDriver.start();
	}
	
	@Test
	public void firstTestCase()
	{
		testDriver.open("/");
		testDriver.windowMaximize();
		testDriver.mouseOver("link=Phones");
		clickAndLoadNextPage("link=all phones");
		
		String priceInPhoneList = testDriver.getText("//div[@class='phoneInfo']/div[3]/span");
		System.out.println("Price in Phone list is : "+priceInPhoneList);
		clickAndLoadNextPage("//div[@class='phoneInfo']/div[4]/a");
		
		testDriver.type("//div[@class='zipField']/input", "95134");
		clickAndLoadNextPage("//div[@class='zipField']/input[2]");
		
		String priceInCart= testDriver.getText("//table[@id='cartDetails']/tbody/tr[4]/td[2]");
	    
	    
		System.out.println("Price in cart is : "+priceInCart);
		System.out.println(priceInCart.substring(1));
		assertEquals(priceInPhoneList,priceInCart );
	}
	
	public void clickAndLoadNextPage(String page)
	{
		testDriver.click(page);
		testDriver.waitForPageToLoad("30000");
	}

	@After
	public void tearDown() throws Exception {
	//testDriver.close();
	}

}
